import axios from 'axios'
import  {Response} from '../types/types'
const instance = axios.create({
  baseURL:'https://www.fastmock.site/mock/70debb041a35bd2ed2dd3e8e4a734384/shop/',
  timeout:10000,
  headers: {'Content-Type': 'application/json'}
})
export  function post(url:string,data={}):Promise<Response<any>>{
    return new Promise((resolve,reject)=>{
      instance.post(url, data)
          .then( (response)=> {
            resolve(response.data);
          })
          .catch( (error)=> {
            reject(error);
          });
    })
}
export function get(url:string,params={}):Promise<Response<any>>{
  return new Promise((resolve,reject)=>{
    instance.get(url,params).then(response=>{
      resolve(response.data)
    }).catch((error)=>{
      reject(error)
    })
  })
}